<?php

namespace App\Controllers\v1;

use Illuminate\Support\Facades\Auth;
use Illuminate\Http\Request;
use common\utils\SysCode;
use App\Controllers\BaseController;
use App\Services\UserService;
use App\Events\UserLogin;
use App\User;
use App\Services\HomeService;

class HomeController extends BaseController
{

    public $allows = ['getNoticeList', 'getHomeMenuList', 'getBanner', 'getDownloadData'];

    //获取网站已开通首页导航
    public function getHome(Request $request)
    {
        $data = HomeService::getHnavigation();
        return $data;
    }

    //首页浮动图广告
    public function getFloat(Request $request)
    {
        $type = $request->get("type", 1);
        $data = HomeService::getFloatList($type);
        return $data;
    }

    //首页banner图
    public function getBanner(Request $request)
    {
        $position = $request->get("position", 7);
        $type = $request->get("type", 1);
        $pf = $type == 1 ? 1 : 2;
        $condition = [
            'language_id' => 1,
            'position' => $position,
            'pf' => $pf,
            'type' => $type,
        ];
        $data = HomeService::getBannerList($condition);
        return $data;
    }

    //pc 获取首页相关数据 egames  menu 首页 电子游艺

    public function getMenu(Request $request)
    {
        $data = HomeService::getMenuIndex();
        return $data;
    }

    //获取视讯列表
    public function getLive(Request $request)
    {
        $data = HomeService::getLiveList();
        return $data;
    }

    //首页导航菜单
    public function getHomeMenu(Request $request)
    {
        $data = HomeService::getHomeMenu();
        return $data;
    }

    //获取首页H5分类
    public function getHomeMenuList(Request $request)
    {
        $data = HomeService::getHomeMenuList();
        return $data;
    }

    //获取H5 首页公告
    public function getNoticeList(Request $request)
    {
        $size = $request->input("size", null);
        $type = $request->input("type", 3);
        $data = HomeService::getNoticeList(Auth::user(), $type, $size);
        return $data;
    }

    //获取已读消息数
    public function getMessageRead(Request $request)
    {
        $userInfo = Auth::user();
        $userId = $userInfo['id'];
        $data = HomeService::getMessageRead($userId);
        return $data;
    }

    //获取首页二维码
    public function getQrcode(Request $request)
    {
        return HomeService::getRrcode();
    }

    //获取热门游戏

    public function getHotGame(Request $request)
    {
        return HomeService::getHotGames();
    }

    //获取首页下载地址
    public function getDownloadData()
    {
        return HomeService::getDownLoadData();
    }
}